﻿using System;

namespace Prime.Services
{
    public class PrimeService
    {
        public bool IsPrime(int candidate)
        {
            if (candidate < 2)
            {
                return false;
            }

            for (var divisor = 2; divisor <= Math.Sqrt(candidate); divisor++)
            {
                if (candidate % divisor == 0)
                {
                    return false;
                }
            }
            return true;
        }

        public int Add(int a, int b)
        {
            return a + b;
        }

        public string GetTriangle(string[] sideArr)
        {
            //throw new NotImplementedException("Please create a sideArr first");
            string result = string.Empty;
            int a = int.Parse(sideArr[0]);
            int b = int.Parse(sideArr[1]);
            int c = int.Parse(sideArr[2]);
            if (a + b > c && a + c > b && b + c > a)
            {
                if (a == b && a == c)
                {
                    result = "等边三角形";
                    return result;
                }

                if (a == b || a == c || b == c)
                {
                    result = "等腰三角形";
                    return result;
                }
                else
                {
                    result = "一般三角形";
                    return result;
                }
            }
            else
            {
                result = "不构成三角形";
            }
            return result;
        }
    }
}
